package net.siufung.market.base.permit.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import net.siufung.core.model.EnumsVo;
import net.siufung.core.model.IEnum;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 陈建峰
 * @since 2022/5/16 3:45 下午
 */
@AllArgsConstructor
public enum BusinessTypes implements IEnum<String> {

    /**
     * 业务端、运营端
     */
    ALL("0", "全部"),
    /**
     * 业务端
     */
    TENANT("1", "业务"),
    /**
     * 运营端
     */
    OPERATE("2", "运营");

    @Getter
    @Setter
    private String value;

    @Getter
    @Setter
    private String desc;


    public static BusinessTypes get(String value) {
        return IEnum.get(BusinessTypes.class,
                enums -> enums.getValue().equals(value));
    }

    public static String getDesc(String value) {
        return IEnum.getDesc(BusinessTypes.class,
                enums -> enums.getValue().equals(value));
    }

    public static List<EnumsVo> getList(){
        return IEnum.findList(BusinessTypes.class).stream()
                .map(element -> new EnumsVo(element.getValue(), element.getDesc()))
                .collect(Collectors.toList());
    }
}
